package com.member.shop.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.member.common.enums.OrderDeleteEnum;
import com.member.common.utils.DateUtils;
import com.member.shop.domain.SysBizCommentPic;
import com.member.shop.mapper.SysBizCommentPicMapper;
import com.member.shop.service.ISysBizCommentPicService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;

/**
 * 评价头像管理Service业务层处理
 *
 * @author lixinchen
 * @date 2024-01-02
 */
@Service
public class SysBizCommentPicServiceImpl extends ServiceImpl<SysBizCommentPicMapper, SysBizCommentPic> implements ISysBizCommentPicService {
    @Resource
    private SysBizCommentPicMapper sysBizCommentPicMapper;

    /**
     * 查询评价头像管理
     *
     * @param id 评价头像管理主键
     * @return 评价头像管理
     */
    @Override
    public SysBizCommentPic selectSysBizCommentPicById(Long id) {
        return sysBizCommentPicMapper.selectById(id);
    }

    /**
     * 查询评价头像管理列表
     *
     * @param sysBizCommentPic 评价头像管理
     * @return 评价头像管理
     */
    @Override
    public List<SysBizCommentPic> selectSysBizCommentPicList(LambdaQueryWrapper<SysBizCommentPic> queryWrapper) {
        return sysBizCommentPicMapper.selectList(queryWrapper);
    }

    /**
     * 新增评价头像管理
     *
     * @param sysBizCommentPic 评价头像管理
     * @return 结果
     */
    @Override
    public int insertSysBizCommentPic(SysBizCommentPic sysBizCommentPic) {
        sysBizCommentPic.setCreateTime(DateUtils.getNowDate());
        return sysBizCommentPicMapper.insert(sysBizCommentPic);
    }

    /**
     * 修改评价头像管理
     *
     * @param sysBizCommentPic 评价头像管理
     * @return 结果
     */
    @Override
    public int updateSysBizCommentPic(SysBizCommentPic sysBizCommentPic) {
        sysBizCommentPic.setUpdateTime(DateUtils.getNowDate());
        return sysBizCommentPicMapper.updateById(sysBizCommentPic);
    }

    /**
     * 批量删除评价头像管理
     *
     * @param ids 需要删除的评价头像管理主键
     * @return 结果
     */
    @Override
    public int deleteSysBizCommentPicByIds(Long[] ids) {
        return sysBizCommentPicMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除评价头像管理信息
     *
     * @param id 评价头像管理主键
     * @return 结果
     */
    @Override
    public int deleteSysBizCommentPicById(Long id) {
        SysBizCommentPic sysBizCommentPic = new SysBizCommentPic();
        sysBizCommentPic.setId(id);
        sysBizCommentPic.setDeleted((long) OrderDeleteEnum.DELETE.getKey());
        return sysBizCommentPicMapper.updateById(sysBizCommentPic);
    }
}
